package com.itstyle.quartz.kettleUtil;

import com.itstyle.quartz.entity.QuartzEntityBatchDt;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

public class PropertyUtil {
    public static String getProperty(Properties prop, String name)
    {
        return prop.getProperty(name);
    }

    public static List<List<QuartzEntityBatchDt>> getListStringArray(List<QuartzEntityBatchDt> allData, int groupSize)
    {
        List<List<QuartzEntityBatchDt>> retList = new ArrayList();

        int groups = 1;
        if (allData.size() > groupSize) {
            groups = allData.size() / groupSize + 1;
        }
        for (int i = 0; i < groups; i++)
        {
            List<QuartzEntityBatchDt> ret = new ArrayList();
            for (int j = 0; j < groupSize; j++)
            {
                int id = j + i * groupSize;
                if (id < allData.size()) {
                    ret.add(allData.get(id));
                }
            }
            retList.add(deleteArrayNull(ret));
        }
        return retList;
    }

    public static List<QuartzEntityBatchDt> deleteArrayNull(List<QuartzEntityBatchDt> string)
    {
       /* String[] strArr = string;

        ArrayList<String> strList = new ArrayList();
        for (int i = 0; i < strArr.length; i++) {
            strList.add(strArr[i]);
        }*/
        while (string.remove(null)) {}
        while (string.remove("")) {}
        //String[] strArrLast = (String[])strList.toArray(new String[strList.size()]);

        return string;
    }

}
